<?php

    class Zend_View_Helper_Likes extends Zend_View_Helper_Partial
    {

        public function getLikes($product_id)
        {
            $commonModel = new Application_Model_Common;
            $likeRecords = $commonModel->getAllRecordDetail(RKN_LIKES, " like_prod_id = '$product_id' ");
            return count($likeRecords);
        }
        
        public function isLogged(){
            
            $x = new Zend_Auth_Storage_Session('User_Auth');
            $y = $x->read();

            $this->user_id = false;
            if (!empty($y))
                $this->user_id = $x->read()->rkn_uid;
            
            return $this->user_id;
        }
        
        public function isLikable($product_id)
        {
            if(!$this->isLogged())
            return false;
            
            $commonModel = new Application_Model_Common;
            $likeRecords = $commonModel->getAllRecordDetail(RKN_LIKES, " like_prod_id = '$product_id' and like_user_id = '".$this->user_id."' ");
            return count($likeRecords)>0?false:true;
        }

    }